File manager - Edit - /home/autoph/public_html/projects/ahg-prf-api/app/Models/Canvass.php
Back
<?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use OwenIt\Auditing\Contracts\Auditable; use OwenIt\Auditing\Auditable as AuditableTrait; use DB; class Canvass extends Model implements Auditable { use HasFactory,SoftDeletes, AuditableTrait; protected $table ='canvass'; protected $guarded=[ 'deleted_at', ]; protected $casts = [ 'created_at' => 'datetime', 'updated_at' => 'datetime', 'deleted_at' => 'datetime', ]; public function supplier() { return $this->belongsTo(Supplier::class)->with('vendor_term'); // Assuming Supplier model exists } public function assetItem() { return $this->hasOne(AssetItem::class, 'id', 'item_id'); } public function mancom_approved() { return $this->hasMany(Approval::class, 'selected_item_id')->where(['transaction_type' => 'purchase-request-item', 'approver_role' => 'execom']); } // public function requiredApprover() // { // // Ensure the total_cost is a float // $totalCost = (float) $this->total_cost; // // Fetch the approval matrix that matches the total cost // return ApprovalMatrix::with('execomOfficerSetup')->where('min_amount', '<=', $totalCost) // ->where('max_amount', '>=', $totalCost) // ->first(); // } public function requiredApprover($company_id,$dealership_id) { // Ensure the total_cost is a float $totalCost = (float) $this->total_cost; // Fetch the approval matrix that matches the total cost and company_id return ApprovalMatrix::with(['execomOfficerSetup' => function($query) use ($company_id,$dealership_id) { $query->where(['company_id' => $company_id,'dealership_id' => $dealership_id]); }]) ->where('min_amount', '<=', $totalCost) ->where('max_amount', '>=', $totalCost) ->first(); } }
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings